import Vue from "vue"
import Router from "vue-router"
import Main from "../view/layout/Main";
import planManagement from "../view/testPlan/planManagement";
import NotFound from "../components/NotFound";
import login from "@/view/auth/login";
import caseManagement from "@/view/testCase/caseManagement";
import statisticsManagementForTest from "@/view/testStatistics/statisticsForTest";
import statisticsManagementForRd from "@/view/testStatistics/statisticsForRd";

import user from "@/view/auth/user";


const routes=[
    {
        path: "/404",
        name: "notFound",
        component: NotFound
    },
    {
        path: "/login", // 此处需特别注意置于最底部
        name: "登录",
        component:login
    },
    {
        path: "/",
        title: "首页",
        component:Main,
        children:[
            {
                path: "/planManagement",
                title:"计划维护",
                component:planManagement
            },
            {
                path: "/caseManagement",
                title:"用例维护",
                component:caseManagement
            },
            {
                path: "/statisticsForTest",
                title:"测试执行统计",
                component:statisticsManagementForTest
            },
            {
                path: "/statisticsForRd",
                title:"研发自测统计",
                component:statisticsManagementForRd
            },
            {
                path: "/user",
                title:"用户维护",
                component:user
            }
        ]


    },
    {
        path:"*",
        redirect:"/404"
    }


];


Vue.use(Router);

const router=new Router({
    routes,
    scrollBehavior: () => {   //禁止浏览器前进后退，不然会导致甘道图无法左右滑动
        history.pushState(null, null, document.URL)
    }
});

const originalPush = Router.prototype.push;
Router.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
};

export default  router;
